package com.violet.domain.result;

import com.violet.domain.po.BuyOrder;
import com.violet.utils.IdUtils;
import lombok.Data;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@Accessors(chain = true)
public class Message {
    private String id;
    private String title;
    private String content;
    private String type;
    private String time;
    private Boolean isRead;

    public static Message newOrder(BuyOrder order) {
       DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
       return new Message()
           .setId(IdUtils.getId("M"))
           .setTitle("新的订单")
           .setType("info")
           .setIsRead(false)
           .setContent("订单ID: " + order.getId())
           .setTime(formatter.format(LocalDateTime.now()));
    }
}
